import {PaginationProps} from   '@arco-design/web-vue';
import {RequestConfig} from '@/libs/config'
import {EmptyUtil} from "@/utils";

export class TplUtil {


    // 将系统默认的分页参数转换为后端可用的分页参数
    static paginationCover(pageSize, current) {
        return {[RequestConfig.pageSize]: pageSize, [RequestConfig.current]: current}
    }

    static totalCover(pagination: PaginationProps, data: any) {
        pagination.total = data[RequestConfig.total]
    }


    /**
     * 弹窗层样式
     * */

    static MODAL_LAYER_TPL = {
        title: '',
        visible: true,
        width: 640,
        closable: true,
        escToClose: true,
        unmountOnClose: true,
        maskClosable: false,
        okButtonProps: {disabled: false, loading: false},
        cancelButtonProps: {disabled: false},
        okText: '确定保存'
    }


    static setRouterRaw(path, title, id: number, parentId=0, componentPath = null, name = null, description = '', icon = 'ri-layout-top-line') {
        const componentName = `${path.replace('/', '')}Page`
        return {
            id: String(id),
            parentId: String(parentId),
            name: EmptyUtil.isNotEmptyString(name) ? name : componentName,
            path:`${path}`,
            component: EmptyUtil.isNotEmptyString(componentPath) ? componentPath : `${path}/index.vue`,
            meta: {
                title, icon,
                dot: false,
                hiddenInTab: false,
                hiddenInMenu: false,
                enableKeepAlive: true,
                dynamicNewTab: true,
                description,
            }
        }
    }

    static setRouterRawH(path, title, id: number, parentId=0, componentPath = null, name = null, description = '', icon = 'ri-layout-top-line') {
        const componentName = `${path.replace('/', '')}Page`
        return {
            id: String(id),
            parentId: String(parentId),
            name: EmptyUtil.isNotEmptyString(name) ? name : componentName,
            path:`${path}`,
            component: EmptyUtil.isNotEmptyString(componentPath) ? componentPath : `${path}/index.vue`,
            meta: {
                title, icon,
                dot: true,
                hiddenInTab: true,
                hiddenInMenu: true,
                enableKeepAlive: true,
                dynamicNewTab: true,
                description,
            }
        }


    }
}
